/**
 * @file    ble_gatts.h
 * @author  Azolla (1228449928@qq.com)
 * @brief   ble gatt server. WiFi Network Configuration.
 * @version 0.1
 * @date    2022-11-03
 * 
 * @copyright Copyright (c) 2022
 * */

#ifndef _BLE_GAP_H_
#define _BLE_GAP_H_

#ifdef __cplusplus
extern "C" {
#endif /**< __cplusplus */

#include "esp_bt.h"
#include "esp_gap_ble_api.h"
#include "esp_gatts_api.h"
#include "esp_gattc_api.h"
#include "esp_bt_defs.h"
#include "esp_bt_device.h"
#include "esp_bt_main.h"
#include "esp_gatt_common_api.h"
#ifdef CONFIG_BLE_MESH
#include "esp_ble_mesh_ble_api.h"
#endif
 
#define CONFIG_BLE_GATT_LOCAL_MTU      64     // BLE-GATT MTU大小 
#define CONFIG_BLE_MESH_ENABLE         0      // 1: 使能MESH与GATT共存(注意：网关是不能MESH共存的)

typedef enum {
    BLE_GATTS_ROLE     = 0x00,
    BLE_GATTC_ROLE     = 0x01,
    BLE_GATT_MAX_ROLE  = 0x02,
} ble_gatt_role_t;

#if CONFIG_BLE_MESH_ENABLE
typedef void (*ble_mesh_gap_callback_t)(esp_ble_mesh_ble_cb_event_t event, esp_ble_mesh_ble_cb_param_t *param);
void ble_mesh_gap_register_callback(ble_mesh_gap_callback_t cb, ble_gatt_role_t event);
void ble_mesh_gap_unregister_callback(ble_gatt_role_t event);
#else
typedef void (*ble_gap_callback_t)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param);
void ble_gap_register_callback(ble_gap_callback_t cb, ble_gatt_role_t event);
void ble_gap_unregister_callback(ble_gatt_role_t event);
#endif

esp_err_t bluedroid_stack_init(void);
void bluedroid_stack_deinit(void);

#ifdef __cplusplus
}
#endif /**< __cplusplus */

#endif /* _GENIE_GATTS_H_ */